﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Xna.Framework.Media;

namespace JustinAngel.UnitedNationsNews.Services
{
    public class MediaLibraryService : IMediaLibraryService
    {
        public void SavePictureOf(FrameworkElement element, string Name)
        {
            var bitmap = new WriteableBitmap(element, null);
            bitmap.Invalidate();
            using(var s = new MemoryStream())
            {
                bitmap.SaveJpeg(s, (int) element.ActualWidth, (int) element.ActualHeight, 0, 80);
                s.Seek(0, SeekOrigin.Begin);
                new MediaLibrary().SavePicture(Name, s);
            }

        }
    }
}
